<?php
require_once '../application/modules/admin/models/Mercadoria.php';

class Admin_MercadoriaController extends Zend_Controller_Action
{
	public function init()
	{
		if(!Zend_Auth::getInstance()->hasIdentity()){
			$this->_redirect('admin/login');
		}
	}

	public  function indexAction()
   	{
      	$model = new Application_Modules_Admin_Model_Mercadoria();
      	$dados = $model->select();
 
      	$this->view->assign("dados", $dados);
   	}
 
   	public function showAction()
   	{
      	$model = new Application_Modules_Admin_Model_Mercadoria();
      	$mercadoria = $model->find($this->_getParam('id'));
 
		$this->view->assign("mercadoria", $mercadoria);
   	}
 
   	public function newAction()
   	{}
 
   	public function createAction()
   	{
      	$model = new Application_Modules_Admin_Model_Mercadoria();
      	$model->insert($this->_getAllParams());
 
      	$this->_redirect('admin/mercadoria/index');
   	}

   	public  function editAction()
   	{
   		$model = new Application_Modules_Admin_Model_Mercadoria();
   		$mercadoria = $model->find($this->_getParam('id'));
   	
   		$this->view->assign("mercadoria", $mercadoria);
   	}
   	
   	public function updateAction()
   	{
   		$model = new Application_Modules_Admin_Model_Mercadoria();
   		$model->update($this->_getAllParams());
   	
   		$this->_redirect('admin/mercadoria/index');
   	}
   	
   	public function destroyAction()
   	{
   		$model = new Application_Modules_Admin_Model_Mercadoria();
   		$model->delete($this->_getParam('id'));
   	
   		$this->_redirect('admin/mercadoria/index');
   	}

}



